﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="EditUser.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.EditUser" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
    $(document).ready(function() {
        $("#frmEditUser").validate({
           rules: {
             First: "required",
             Last: "required",
             Phone: "required",
             Email: {
                   required: true,
                   email: true
             }         
           },
           
           errorLabelContainer:"#frmEditUserErr",
           messages: {
             First: "Please enter a first name",
             Last: "Please enter a last name",
             Phone: "Please enter a phone number",
             Email:    {
                required: "Please enter an email address",
                email:    "The email address must be in the proper format"                
             }
           }
        });
    });
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <% LBRDataContext dc = new LBRDataContext();  %>
    <% User u = dc.GetUser(ViewData["UserId"].ToString()); object vals = new { id = u.UserId.ToString() };  %>
    <div class="contentDiv" style="margin-left:25%">
        <form method="post" id="frmEditUser" enctype="multipart/form-data" action="<%=  Url.Action("SaveOrUpdateUser", "Admin", vals ) %>" >
            
            
                <fieldset id="fldRegister" style="width:300px;display:block;">
                    <legend><%= u.UserId == null ? "New" : "Edit" %> User</legend>
                    <table>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label">User Name:&nbsp;</label></td>
                        <td class="addPropertyField"><%= u.UserName %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="First">First:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.TextBox("First", u.First) %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="Last">Last:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.TextBox("Last", u.Last) %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="Phone">Phone:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.TextBox("Phone", u.Phone) %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="Email">Email:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.TextBox("Email", u.Email) %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="Admin">Has an agent?:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.CheckBox("Agent", u.HasAgent) %></td>
                    </tr>
                    <tr class="addPropertyRow">
                        <td class="addPropertyLabel"><label class="label" for="Admin">Is Admin?:&nbsp;</label></td>
                        <td class="addPropertyField"><%= Html.CheckBox("Admin", u.IsAdmin) %></td>
                    </tr>
                    <tr>
                        <td colspan="2"><div id="frmEditUserErr" class="ValidateErrorContainer"></div></td>
                    </tr>
                    </table>
                </fieldset>
                <%= Html.Hidden("UserName", u.UserName) %>
                <div style="display:inline">
                    <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                    <button onclick="window.location='../Admin.ashx/UserList'; return false;">Cancel</button>
                </div>        
        </form>
    </div>
</asp:Content>
